import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec

# Subplot分隔显示
# method 1: subplot2grid
################################
# plt.figure()
# ax1 = plt.subplot2grid((3, 3), (0, 0), colspan=3,rowspan=1)
# ax1.plot([1, 2], [1, 2])    # 画小图
# ax1.set_title('ax1_title')  # 设置小图的标题
#
# ax2 = plt.subplot2grid((3, 3), (1, 0), colspan=2)
# ax3 = plt.subplot2grid((3, 3), (1, 2), rowspan=2)
# ax4 = plt.subplot2grid((3, 3), (2, 0))
# ax5 = plt.subplot2grid((3, 3), (2, 1))
#
# plt.show()

# method 2: gridspec
################################
plt.figure()
gs=gridspec.GridSpec(3,3)

ax6 = plt.subplot(gs[0, :])
ax7 = plt.subplot(gs[1, :2])
ax8 = plt.subplot(gs[1:, 2])
ax9 = plt.subplot(gs[-1, 0]) # <=> ax9 = plt.subplot(gs[2, 0])
ax10 = plt.subplot(gs[-1, -2]) # <=> ax10 = plt.subplot(gs[2, 1])

plt.show()

# method 3: easy to define structure
#############################################
# f, ((ax11, ax12), (ax13, ax14)) = plt.subplots(2, 2, sharex=True, sharey=True)
#
# ax11.scatter([1,2], [1,2])
# plt.tight_layout()
# plt.show()
